require("../../../@babel/runtime/helpers/Arrayincludes");

var t = getApp();

Page({
    data: {
        fictitious: "",
        status: "0",
        list: [],
        id: ""
    },
    onLoad: function(t) {
        this.setData({
            id: t.id
        }), this.getData();
    },
    onChangeNum: function(t) {
        this.setData({
            fictitious: t.detail
        });
    },
    submit: function() {
        var a = [];
        this.data.list.forEach(function(t) {
            a.push({
                category_id: t.id,
                tel_content: {
                    amount: t.amount
                },
                line_content: {
                    amount: t.online,
                    day: t.day
                }
            });
        });
        var i = {
            id: this.data.id,
            form: {
                fictitious: this.data.fictitious,
                status: this.data.status,
                data: a
            }
        };
        t._postNetWork({
            url: t.getNetAddresss("plugin.lawyer-platform.frontend.controllers.lawyer.serviceSave"),
            data: i,
            success: function(a) {
                1 == a.data.result ? (t.tips(a.data.msg), wx.navigateBack()) : t.tips(a.data.msg);
            }
        });
    },
    getData: function() {
        var a = this;
        t._getNetWork({
            url: t.getNetAddresss("plugin.lawyer-platform.frontend.controllers.lawyer.serviceShow"),
            data: {
                id: this.data.id
            },
            success: function(t) {
                if (1 == t.data.result) {
                    var i = t.data.data.lawyer.category_data;
                    if (i.forEach(function(t) {
                        t.amount = "", t.online = "", t.day = "";
                    }), a.setData({
                        fictitious: t.data.data.lawyer.fictitious,
                        status: t.data.data.lawyer.status + "",
                        list: i
                    }), null !== t.data.data.lawyer.service) {
                        var n = t.data.data.lawyer.service.data, e = [], o = [];
                        i.forEach(function(t, a) {
                            e.push(t.id);
                        }), n.forEach(function(t) {
                            e.includes(t.category_id) && o.push({
                                id: t.category_id,
                                amount: t.tel_content.amount,
                                online: t.line_content.amount,
                                day: t.line_content.day
                            });
                        }), o.forEach(function(t) {
                            a.data.list.forEach(function(a) {
                                t.id == a.id && (a.amount = t.amount, a.online = t.online, a.day = t.day);
                            });
                        }), a.setData({
                            list: a.data.list
                        });
                    }
                }
            }
        });
    },
    onChange: function(t) {
        var a = t.detail.replace(/[^0-9]/g, ""), i = t.currentTarget.dataset.value, n = t.currentTarget.dataset.index;
        this.data.list[n][i] = a, this.setData({
            list: this.data.list
        });
    },
    onChangeStatus: function(t) {
        this.setData({
            status: t.detail
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});